package two;

import java.util.ArrayList;
import java.util.List;


    public class Student {


        private String name;
        private int age;
        private int score;
        private String classNum;
        public int getScore() {
            return score;
        }
        public void setScore(int score) {
            this.score = score;
        }
        public int getAge() {
            return age;
        }
        public void setAge(int age) {
            this.age = age;
        }
        public Student(String name,int age,int score,String classNum)
        {
            this.name=name;
            this.age=age;
            this.score=score;
            this.setClassNum(classNum);
        }
        public static void main(String[] args) {
            List<one.Student> list = new ArrayList<>();

            list.add(new one.Student("Tom",18,100, "class05"));
            list.add(new one.Student("Jerry",22,70, "class04"));
            list.add(new one.Student("Owen",25,90, "class05"));
            list.add(new one.Student("Jim",30,80,"class05"));
            list.add(new one.Student("Kevin",24,100,"class04"));
            list.add(new one.Student("Steve",28,66,"class06"));
            float All = 0;
            float a=0,b=0,c=0;
            for(one.Student i:list)
            {
                All+=i.getAge();
                if((i.getClassNum().equals("class05"))==true)
                {
                    a=a+i.getScore();
                }

                if((i.getClassNum().equals("class06"))==true)
                {
                    c+=i.getScore();
                }
                if((i.getClassNum().equals("class04"))==true)
                {
                    b=b+i.getScore();
                }
            }

            System.out.println("所有班的平均年龄是："+All/list.size());
            System.out.println("5班的平均成绩是："+a/3);
            System.out.println("4班的平均成绩是："+b/2);
            System.out.println("6班的平均成绩是："+c/1);

        }
        public String getClassNum() {
            return classNum;
        }
        public void setClassNum(String classNum) {
            this.classNum = classNum;
        }

    }
